<template>
  <div>
    <p>为你的问题选择一种题目类型</p>
    <div class="types">
      <section v-for="(type, index) in types" class="type"
      :class="[active === type.id ? 'active' : '']" :key="index"
      @click="choose(type.id)">
        <div class="img">
          <img :src="type.img">
        </div>
        <span>{{type.des}}</span>
      </section>
    </div>
  </div>
</template>

<script>
export default {
  name: 'surveyIndex2',
  data () {
    return {
      types: [
        {
          img: '/static/images/type1.png',
          des: '单选题',
          id: 1
        },
        {
          img: '/static/images/type3.png',
          des: '多选题',
          id: 2
        },
        {
          img: '/static/images/type5.png',
          des: '滑动题',
          id: 3
        },
        {
          img: '/static/images/type7.png',
          des: '定量题',
          id: 4
        },
        {
          img: '/static/images/type9.png',
          des: '排序题',
          id: 5
        },
        {
          img: '/static/images/type11.png',
          des: '选图题',
          id: 6
        },
        {
          img: '/static/images/type11.png',
          des: '填写题',
          id: 7
        }
      ],
      active: -1
    }
  },
  methods: {
    choose (index) {
      this.$emit('choose', index)
      this.next()
    },                           // 选择一个题目类型
    next () {
      this.$router.push({name: 'surveyIndex3'})
    }                            // 下一步进入选择有图无图页
  }
}
</script>

<style lang="scss" scoped>
p {
  font-size: 48px;
  line-height: 80px;
  color: #2e3192;
  text-align: center;
  font-weight: lighter;
  max-width: 400px;
  margin: 35px auto;
}
.types {
  width: 600px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .type {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 276px;
    flex: none;
    margin-bottom: 40px;
    &.active {
      box-shadow: 0 0 0 8px #3d68be;
    }
  }
  span {
    font-size: 32px;
    color: #999;
  }
  img {
    width: 100%;
    height: 100%;
  }
}
</style>

